﻿
function GetTagsString() {
    //alert('GetTagsString');
    var values = [];
    $('#allowSpacesTags span.tagit-label').each(function () {
        //alert($(this).text());
        values.push($(this).text());
    });
    $("#ctl00_MainContent_hdnSelectedTags").val(values.join(","));
}
var millisecondsToWait = 5000;

function ClearSaveMsg() {

    alert('ss');
    $("#ctl00_MainContent_lblSaveMsg").fadeOut(9000);
    setTimeout(function () {
        $("#ctl00_MainContent_lblSaveMsg").empty();
        $("#ctl00_MainContent_lblSaveMsg").text("");
    }, millisecondsToWait);

};

function ClearSaveMsgAlert() {
    //alert('ss');
    $("#ctl00_MainContent_lblSaveMsg").fadeOut(5000);
    $("#ctl00_MainContent_lblSaveMsg").empty();
    $("#ctl00_MainContent_lblSaveMsg").text("");
};

function BeginRequestHandler() {
    alert('BeginRequestHandler');
    $("#ctl00_MainContent_gvJobList input[id*='chkboxSelectAll']:checkbox").click(function () {
        //Check/uncheck all checkboxes in list according to main checkbox 
        $("#ctl00_MainContent_gvJobList  input[id*='chkDelete']:checkbox").attr('checked', $(this).is(':checked'));

        var len = $("input[type=checkbox][id*=chkDelete]:checked").length
        var length = parseInt(len);
        var m = 0;
        if (length == 0) {
            $('#ctl00_MainContent_btnDeleteSeledRows').attr("disabled", true);
        }
        else {
            $('#ctl00_MainContent_btnDeleteSeledRows').attr("disabled", false);
        }
    });
    $("#ctl00_MainContent_gvJobList  input[id*='chkDelete']:checkbox").click(
        function () {
            //alert('disableButton' + $("input[type=checkbox][id*=chkDelete]:checked").length);

            var len = $("input[type=checkbox][id*=chkDelete]:checked").length
            var length = parseInt(len);
            var m = 0;
            if (length == 0) {
                $('#ctl00_MainContent_btnDeleteSeledRows').attr("disabled", true);
            }
            else {
                $('#ctl00_MainContent_btnDeleteSeledRows').attr("disabled", false);
            }
        });

    $('# $("#ctl00_MainContent_gvJobList').change(function () {
        if ($(this).val() == "Deadline") {
            $('# $("#ctl00_MainContent_lblMsg').text('i.e. 10 (in days)');
        }
        else {
            $('# $("#ctl00_MainContent_lblMsg').text('');
        }
    });
    if ($('# $("#ctl00_MainContent_txtSearch').val() == "" || $('# $("#ctl00_MainContent_txtSearch').val() == null || $('# $("#ctl00_MainContent_txtSearch').val() == 'Write text and press enter') {
        var watermark = 'Write text and press enter';
        $('# $("#ctl00_MainContent_txtSearch').blur(function () {
            if ($(this).val().length == 0)
                $(this).val(watermark).addClass('watermark');
        }).focus(function () {
            if ($(this).val() == watermark)
                $(this).val('').removeClass('watermark');
        }).val(watermark).addClass('watermark');
    }
}